/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("Warehouseoutinfo",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Entity.DomainModels;
using WareHouse.Write.System.IServices;
using SqlSugar;
using Microsoft.AspNetCore.Authorization;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using VOL.Entity.DTO;
using BusFin.Read.Entity.DomainModels;
using StackExchange.Redis;
using BusFin.Read.Entity.MappingConfiguration;

namespace WareHouse.Write.System.Controllers
{
    public partial class WarehouseoutinfoController
    {
        private readonly IWarehouseoutinfoService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly ISqlSugarClient _db;
        [ActivatorUtilitiesConstructor]
        public WarehouseoutinfoController(
            IWarehouseoutinfoService service,
            IHttpContextAccessor httpContextAccessor,
            ISqlSugarClient db
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
            _db = db;
        }

        [HttpGet, Route("GetPageDatas"), AllowAnonymous]
        public IActionResult GetPageDatas(PageDataOptions options)
        {
            return Ok(_service.GetPageData(options));
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("GetProductAll"), AllowAnonymous]
        public IActionResult GetProductAll()
        {
          var list=  _db.Queryable<wareHouse, Product>((o, i) => new JoinQueryInfos(JoinType.Left, o.wareHouseId == i.DefaultRepository))
         .Select((o, i) => new WareHouseAndProductDTO
         {
             StockOut = i.StockOut,
             DefaultCustomer = i.DefaultCustomer,
             DefaultRepository = i.DefaultRepository,
             wareHouseId = o.wareHouseId,
             DefaultLibraryLocation = i.DefaultLibraryLocation,
             DefaultSupplier = i.DefaultSupplier,
             Describe = i.Describe,
             EarlyWarningBelow = i.EarlyWarningBelow,
             EarlyWarningFront = i.EarlyWarningFront,
             InsideId = i.InsideId,
             IsDeleted = i.IsDeleted,
             Price = i.Price,
             ProductId = i.ProductId,
             ProductName = i.ProductName,
             SortId = i.SortId,
             Specification = i.Specification,
             StartStock = i.StartStock,
             StockIn = i.StockIn,
             SumStock = i.SumStock,
             SupplierId = i.SupplierId,
             UnitId = i.UnitId,
             wareHouseAddr = o.wareHouseAddr,
             wareHouseArea = o.wareHouseArea,
             wareHouseDepartment = o.wareHouseDepartment,
             wareHouseDesc = o.wareHouseDesc,
             wareHouseIsDefule = o.wareHouseIsDefule,
             wareHouseIsDelete = o.wareHouseIsDelete,
             wareHouseIsDisable = o.wareHouseIsDisable,
             wareHouseLeaseTime = o.wareHouseLeaseTime,
             wareHouseLinkman = o.wareHouseLinkman,
             wareHouseName = o.wareHouseName,
             wareHousePhone = o.wareHousePhone,
             wareHouseType = o.wareHouseType,
             Weight = i.Weight
         }).ToList();
            return Ok(list);
        }

    }
}
